#include<stdio.h>
#include<string.h>
#include<sys/types.h>
#include<sys/types.h>
#include<unistd.h>
#include <fcntl.h>
int main()
{
    /*FILE* pf = fopen("log.txt","r");
    if(pf==NULL) 
    {
        perror("open");
        return 1;
    }
    const char* message="hello world\n";
    char ch[64]={0};

    //fprintf(pf,"%s",message);
    //fwrite(message,1,strlen(message),pf);
   // fscanf(pf,"%s",ch);
    //fread(ch,1,64,pf);
    //fputs(message,pf);
    //fgets(ch,64,pf);
    printf("%s\n",ch);
    fclose(pf);*/
    umask(0);
    //int fd=open("log.txt",O_WRONLY | O_CREAT |  O_TRUNC,666);
    int fd=open("log.txt",O_RDONLY,666);

    if(fd<0) 
    {
        perror("open");
        return 1;
    } 
    const char* m="hello bit\n";
    write(fd,m,strlen(m));
    char ch[64]={0};
    read(fd,ch,64);
    printf("%s",ch);
    close(fd);
    return 0;
}